import { axios } from '@/utils/request'

const api = {
  login: 'user/login',
  loginByHid: 'user/login-by-hid',
  logout: 'user/logout',
  loginPageWays: 'login-way/on-login-page',
  config: 'basic-info',
  info: 'user/get-by-token',
  changePwd: 'user/changePwd'
}

/**
 * 账户登录
 * @param {*} data
 */
export function login(data) {
  return axios({
    url: api.login,
    method: 'post',
    data
  })
}

/**
 * hid登录
 * @param {*} data
 */
export function loginByHid(data) {
  return axios({
    url: api.loginByHid,
    method: 'post',
    data
  })
}

/**
 * 退出登录
 */
export function logout() {
  return axios({
    url: api.logout,
    method: 'delete'
  })
}

/**
 * 获取用户信息
 */
export function getInfo(params) {
  return axios({
    url: api.info,
    method: 'get',
    params
  })
}

/**
 * 获取登录页配置信息
 */
export function readConfig() {
  return axios({
    url: api.config,
    method: 'get'
  })
}

/**
 * 获取登录方式
 */
export function readLoginPageWays() {
  return axios({
    url: api.loginPageWays,
    method: 'get'
  })
}

/**
 * 修改密码
 * @param {*} data
 */
export function updatePassword(data) {
  return axios({
    url: api.changePwd,
    method: 'put',
    data
  })
}

/**
 * 获取账户路由菜单权限
 * @param {*} params
 */
export function getAuth(params) {
  return axios({
    url: 'mos/authority/perm/action/listByName',
    method: 'get',
    params
  })
}




/**
 * 获取其他项目url
 * @param {*} params
 */
export function getAppUrl(params) {
  return axios({
    url: 'app/getRequestUrl',
    method: 'get',
    params
  })
}